package com.plan.controller.user;

import com.plan.base.constant.BaseCode;
import com.plan.base.entity.Result;
import com.plan.controller.user.request.MiniProgramLoginRequest;
import com.plan.controller.user.response.LoginResponse;
import com.plan.service.uesr.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("public/user")
public class LoginController {
    @Resource
    private UserService userService;

    /**
     * 登陆
     */
    @PostMapping(value = "wxLogin")
    public Result<LoginResponse> wxLogin(@RequestBody MiniProgramLoginRequest request, HttpServletResponse httpResponse) {
        if (request.getLoginCode() == null) {
            return Result.fail(BaseCode.PARAM_ERROR);
        }
        return userService.wxLogin(request);
    }

}
